import React, {lazy} from "react";
import {useRoutes} from "react-router-dom";
const Literature = lazy(() => import("../page/Literature"));
const Article = lazy(() => import("../page/Article"));
const Region = lazy(() => import("../page/Region"));
const LiteratureDetail = lazy(() => import("../page/Literature/child/LiteratureDetail"));
const ArticleDetail = lazy(() => import("../page/Article/child/ArticleDetail"));
const RegionDetail = lazy(() => import("../page/Region/child/RegionDetail"));
const Home = lazy(() => import("../page/Home"));

const Router = () => {
    // 路由
    return useRoutes([
        {
            path: "/",
            element: <Home/>
        },
        {
            path: "/literature",
            children: [
                {
                    path: "",
                    element: <Literature/>
                },
                {
                    path: ":id",
                    element: <LiteratureDetail/>
                }
            ]
        },
        {
            path: "/article",
            children: [
                {
                    path: "",
                    element: <Article/>,
                },
                {
                    path: ":id",
                    element: <ArticleDetail/>
                }
            ]
        },
        {
            path: "/region",
            children: [
                {
                    path: "",
                    element: <Region/>
                },
                {
                    path: ":id",
                    element: <RegionDetail/>
                }
            ]
        },
        {
            path: "/*",
            element: <h1 style={{textAlign: "center"}}>404不存在</h1>
        }
    ])
}

export default Router;